#include "stdafx.h"
#include "ccube.h"

CCube::CCube(void)
{

}

CCube::~CCube(void)
{
}

void CCube::setPosition(int x, int y, int z){
	px = x;
	py = y;
	pz = z;
}
void CCube::setRotation(double pitch, double yaw, double roll){
	rx = pitch;
	ry = yaw;
	rz = roll;
}
void CCube::setScale(double x, double y, double z){
	sx = x;
	sy = y;
	sz = z;
}
void CCube::setColor(double r, double g, double b){
	cr = r;
	cg = g;
	cb = b;
}
void CCube::draw(bool solid){

	glPushMatrix();

	glTranslatef(px, py, pz);//valores de nuestras variables globales
	glScalef(sx, sy, sz);
	glColor3f(cr, cg, cb);

	if(!solid){
		glBegin(GL_LINE_STRIP);
	}
	glBegin(GL_QUADS);  
	

	//Cara de Frente 
	glNormal3fv(-1, -1, -1);
	glVertex3f(0.0f, 1.0f, 1.0f); 
	glVertex3f(0.0f, 0.0f, 1.0f); 
	glVertex3f(1.0f, 0.0f, 1.0f); 
	glVertex3f(1.0f, 1.0f, 1.0f); 

	//Cara de Detras 
	glNormal3fv(-1, -1, -1);
	glVertex3f(0.0f, 1.0f, 0.0f); 
	glVertex3f(1.0f, 1.0f, 0.0f); 
	glVertex3f(1.0f, 0.0f, 0.0f); 
	glVertex3f(0.0f, 0.0f, 0.0f); 

	//Cara de dcha
	glNormal3fv(-1, -1, -1);
	glVertex3f(1.0f, 1.0f, 0.0f); 
	glVertex3f(1.0f, 1.0f, 1.0f); 
	glVertex3f(1.0f, 0.0f, 1.0f); 
	glVertex3f(1.0f, 0.0f, 0.0f); 

	//Cara de izda
	glNormal3fv(-1, -1, -1);
	glVertex3f(0.0f, 1.0f, 1.0f); 
	glVertex3f(0.0f, 1.0f, 0.0f); 
	glVertex3f(0.0f, 0.0f, 0.0f); 
	glVertex3f(0.0f, 0.0f, 1.0f); 

	//Cara de arriba
	glNormal3fv(-1, -1, -1);
	glVertex3f(0.0f, 1.0f, 0.0f); 
	glVertex3f(0.0f, 1.0f, 1.0f); 
	glVertex3f(1.0f, 1.0f, 1.0f); 
	glVertex3f(1.0f, 1.0f, 0.0f); 

	//Cara de abajo
	glNormal3fv(-1, -1, -1);
	glVertex3f(0.0f, 0.0f, 0.0f); 
	glVertex3f(1.0f, 0.0f, 0.0f); 
	glVertex3f(1.0f, 0.0f, 1.0f); 
	glVertex3f(0.0f, 0.0f, 1.0f); 

	glEnd();

	glPopMatrix();
}
